MySQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as C2 on C2.TOBJID=C1.OBJID LEFT JOIN c_author au ON au.ID=C1.AUTHORID lef' at line 27

show sql text »
1: SELECT C1.ID, C1.NAME, t.TITLE NAME1, C1.DESCRIPTION, C1.DISTRIBUTION,
2: C1.TAXON, C1.OBJID,
3: C1.AUTHORID AUID, au.NAME AUNAME, C1.AYEAR, C1.ABRACK, C1.AYEARREM,
4: C2.DETDESC DETDESC_FM, C2.ID C2ID, C2.NAME C2NAME, C2.NAME1 C2NAME1,
5: C1.ORIGSP,
6: C1.STATE_IDIMAGE, C1.TAXA_TYPE, C1.ORIGGEN, C1.ORIGSUBGEN,
7: ogn.NAME OGNNAME, osg.NAME OSGNAME,
8: gn.ID GNID, gn.NAME GNNAME, sgn.ID SGNID, sgn.NAME SGNNAME, C1.RANK,
9: (get_taxa_icon(C1.ID)) CLASS_ICONID, C1.TAXA_REMARK, C1.REFID, C1.TAXON,
10:
11: (SELECT COUNT(*)
12: FROM (
13: SELECT MIN(ID) ID FROM articles a
14: WHERE a.CLASSID=1493
15: AND (a.DATE_TIME <> '' OR a.PLACE <> '')
16: GROUP BY a.DATE_TIME, a.PLACE
17: ) as DS
18:
19: )
20: DISTRCNT
21: FROM classes C1
22: LEFT JOIN
23: (SELECT t.OBJID TOBJID, c2.ID, c2.DETDESC, c2.NAME, c2.NAME1
24: from classobj_tree t
25: JOIN classes c2 ON c2.OBJID=t.POBJID AND c2.RANK=13
26: WHERE t.OBJID=
27: ) as C2 on C2.TOBJID=C1.OBJID
28:
29: LEFT JOIN c_author au ON au.ID=C1.AUTHORID
30: left join languages l on l.CODE='en'
31: left join titles t on t.LANGID=l.ID AND t.SIGNATURE='classes' and t.POBJID=C1.OBJID
32: left join classes ogn on ogn.ID = C1.ORIGGEN
33: left join classes osg on osg.ID = C1.ORIGSUBGEN
34: LEFT JOIN classes gn ON gn.OBJID =
35: (CASE WHEN C1.RANK=2
36: THEN (SELECT t.POBJID
37: FROM classobj_tree t
38: WHERE t.OBJID=C1.OBJID AND t.PRANK=7 LIMIT 1 )
39: ELSE NULL
40: END)
41: LEFT JOIN classes sgn ON sgn.OBJID =
42: (CASE WHEN C1.RANK=2
43: THEN (SELECT t.POBJID
44: FROM classobj_tree t
45: WHERE t.OBJID=C1.OBJID AND t.PRANK=6 LIMIT 1 )
46: ELSE NULL
47: END)
48: WHERE C1.ID=1493